package ishitong.vehicleManagement.service.biz.impl;

import ishitong.vehicleManagement.dao.SpecialPlateDao;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.ishitong.platform.common.page.Page;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.ArrayList;
import ishitong.vehicleManagement.model.FakePlateVehicle;
import ishitong.vehicleManagement.model.SpecialPlate;
import ishitong.vehicleManagement.model.SpecialPlateQuery;
import ishitong.vehicleManagement.service.biz.SpecialPlateService;

/** @pdOid e47386e1-edcf-47b9-8424-4dc6357c7072
 * @创建日期:2013-09-27 12:15:24
 * 
 * @功能描述:RVIMS_SpecialPlate业务服务
 * @开发人员:福建视通 */
@Service(value="specialPlateService")
@Transactional
public class SpecialPlateServiceImpl implements SpecialPlateService {
   /** @pdOid 987b27b8-5995-4d3b-aa91-627d0effdede
       @pdRoleInfo migr=yes name=SpecialPlateDao assc=association3 */
   @Autowired
   private SpecialPlateDao specialPlateDao;
   /** @pdOid ad129cc8-b245-4125-8787-2d2f6af925c5
       @pdRoleInfo migr=yes name=SPISysCodeService assc=association14 */
   @Autowired
   private SPISysCodeService spiSysCodeService;
   
   /** @param sp
    * @pdOid 3204cf6e-9870-4c9b-b666-5d92bf5df2d1 */
   private void setSpecialPlateProperty(SpecialPlate sp) {
   //	   sp.setPlateColor(spiSysCodeService.getSysCodeById( sp.getPlateColorId()));
   	   sp.setPlateType(spiSysCodeService.getSysCodeById(sp.getPlateTypeId()));
   //	   sp.setVehicleClassification(spiSysCodeService.getSysCodeById(sp.getVehicleClassificationId()));
   	   sp.setMatchWay(spiSysCodeService.getSysCodeById(sp.getMatchWayId()));
   //	   sp.setVehicleType(spiSysCodeService.getSysCodeById(sp.getVehicleTypeId()));
      }
   
   /** @param id
    * @pdOid a294485a-27cf-4797-ac71-f8155e1ba3fa
    * @功能描述: 删除RVIMS_SpecialPlate
    * @异常类型: */
   public void delete(String id) {
   	if(id!=null&&!id.trim().equals("")){
   		String[] idList=id.split(";");
   		for(int i=0;i<idList.length;i++){
   			if(idList[i]!=null&&!idList[i].trim().equals("")){
   				this.specialPlateDao.remove(idList[i]);
   			}
   		}
   	}
   }
   
   /** @param specialPlate
    * @pdOid 921c56ef-e76a-4830-b006-28adb158a1b7
    * @功能描述: 删除RVIMS_SpecialPlate
    * @异常类型: */
   public void deleteByModel(SpecialPlate specialPlate) {
   	this.specialPlateDao.remove(specialPlate);
   }
   
   /** @param id
    * @pdOid d767dc73-396f-4442-b523-dc1fc38faedb
    * @功能描述: 查询RVIMS_SpecialPlate
    * @异常类型: */
   public SpecialPlate findById(String id) {
   	return this.specialPlateDao.findByPrimaryKey(id);
   }
   
   /** @param specialPlate
    * @pdOid 66af5773-f175-4a36-9e54-d81189419da3
    * @功能描述: 新增与修改RVIMS_SpecialPlate
    * @异常类型: */
   public void save(SpecialPlate specialPlate) {
   	this.specialPlateDao.save(specialPlate);
   }
   
   /** @param query 
    * @param pageSize 
    * @param pageNum
    * @pdOid 24329a37-f82d-4c18-9316-78fba14e4983
    * @功能描述: 通过SpecialPlateQuery对象，查询RVIMS_SpecialPlate
    * @异常类型: */
   public Page findPage(SpecialPlateQuery query, int pageSize, int pageNum) {
    Page<SpecialPlate> page = this.specialPlateDao.findPage(query,pageSize,pageNum);
     List<SpecialPlate> lst = page.getResults();
     for (SpecialPlate sp: lst) {
     	setSpecialPlateProperty(sp);
     }
   return page;
   }
   
   /** @param query
    * @pdOid ee2fba7e-1973-470e-b1a3-9cfc7728c994
    * @功能描述: 通过SpecialPlateQuery对象，查询RVIMS_SpecialPlate
    * @异常类型: */
   public List<SpecialPlate> findList(SpecialPlateQuery query) {
   	return this.specialPlateDao.findList(query);
   }

}